home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / SAT 2.3.8 / Demos / StepPlatform Demo ƒ / InformUser.c < prev    next >
Text File  |  1996-05-11  |  3KB  |  136 lines

  1. /**************************************
  2. * displaying information on the screen
  3. *    and updating it.
  4. **************************************/
  5. #include "SAT.h"
  6. #include "myPlatform.h"
  7.  
  8. extern    SpritePtr    playerSp;
  9.  
  10. #ifndef abs
  11. #define abs(x)    (x>0?x:-x)
  12. #endif
  13.  
  14.  
  15. Str255    *aActionMsg[10];
  16. short    lastActMsg = -1;
  17.  
  18. void    InitInformationArea(void)
  19. {
  20.         StringHandle    sh;
  21.         short        i=0;
  22.         Rect        r;
  23.         SATPort        tmpPort;
  24.         
  25.         do
  26.         {
  27.             sh = GetString(128+i);
  28.             if (sh)
  29.                 aActionMsg[i] = (Str255*) sh[0];
  30.             i++;
  31.         }
  32.         while ((i<ActionMsgNumber)&&(sh));
  33.         
  34.         SATGetPort(&tmpPort);
  35.         DrawProgInfo(playerSp);
  36.         SetRect(&r,0,0,gSAT.offSizeH,gSAT.offSizeV);
  37.         SATBackChanged(&r); /*Let SAT show it on screen*/        
  38.         SATSetPort(&tmpPort);
  39. } //InitInformationArea
  40.  
  41. void DrawProgInfo(SpritePtr    me)
  42. {    
  43.         Str255    s;
  44.         Rect    r;
  45.     
  46.         SetPort(gSAT.backScreen.port);
  47.         BackColor(blackColor);
  48.         
  49.         SetRect(&r, 0, 0, gSAT.bounds.right, 18);
  50.         
  51.         ForeColor(blueColor);
  52.         EraseRect(&r);
  53.         PenNormal();
  54.         
  55.         FrameRect(&r);
  56.         SetRect(&r, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  57.         FrameRect(&r);
  58.         
  59.         ForeColor(redColor);
  60.         MoveTo(10, 13);
  61.         DrawString("\pThis is a Demo for Scrolling and Platform Game.(made by Nissan Zafrir 1995)");
  62.  
  63.         SetRect(&r, 1, 350, gSAT.offSizeH-150, 366);
  64.         EraseRect(&r);
  65.         ForeColor(yellowColor);
  66.         
  67.         MoveTo(10, 362);
  68.         DrawString("\pSpeed.V = ");
  69.  
  70. /*** Displaying SpeedV info ***\
  71. NumToString(me->speed.v, s);
  72. MoveTo(100, 362);
  73. DrawString("\pSpeed.V = ");
  74. MoveTo(170, 362);
  75. DrawString(s);
  76. *******************************/
  77.         MoveTo(110,362);
  78.         DrawString("\pAction = ");
  79.         
  80.         MoveTo(700,362);
  81.         DrawString("\pH = ");
  82.         
  83. /*** Displaying PositionV info ***\
  84. MoveTo(350,362);
  85. DrawString("\pV = ");
  86. MoveTo(370,362);
  87. NumToString(me->position.v, s);
  88. DrawString(s);
  89. **********************************/
  90.         ForeColor(blackColor);
  91.         BackColor(whiteColor);
  92. } //DrawProgInfo
  93.  
  94. void UpdateInfo(PlSpritePtr    me)
  95. {    
  96.         Str255    s;
  97.         StringHandle    sh;
  98.         Rect    r;
  99.     
  100.         BackColor(blackColor);
  101.         ForeColor(yellowColor);
  102.         
  103.         SetRect(&r, 80, 350, 110, 366);
  104.         EraseRect(&r);
  105.         NumToString(me->speed.v, s);
  106.         MoveTo(80, 362);
  107.         DrawString(s);
  108.         
  109.         if (me->action != lastActMsg) {
  110.             SetRect(&r, 165, 350, 310, 366);
  111.             EraseRect(&r);
  112.             MoveTo(165,362);
  113.             DrawString(*aActionMsg[ lastActMsg=me->action ]);
  114.         }
  115.         SetRect(&r, 720, 350, 750, 366);
  116.         EraseRect(&r);
  117.         MoveTo(720,362);
  118.         NumToString(me->position.h, s);
  119.         DrawString(s);
  120.         
  121.         ForeColor(blackColor);
  122.         BackColor(whiteColor);
  123. } //UpdateInfo
  124.  
  125. void DrawProgrammerInfo(void)
  126. {
  127.         Str255        s;
  128.         Rect        r;
  129.         SATPort        tmpPort;
  130.  
  131.         SATGetPort(&tmpPort);
  132.         SATSetPortScreen();
  133.         UpdateInfo((void *)playerSp);
  134.         SATSetPort(&tmpPort);
  135. } //DrawProgrammerInfo
  136.